package com.phpxiu.app.adapter;

import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;

import com.phpxiu.app.adapter.holder.MyBlackViewHolder;
import com.phpxiu.app.kkylive.R;
import com.phpxiu.app.model.list.BlackUser;

import java.util.List;

/**
 * Created by 吴金洲 on 2016/8/3
 */
public class MyBlackListAdapter extends BaseAdapter<BlackUser> {
    public MyBlackListAdapter(Context context, List<BlackUser> data) {
        super(context, data);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        BlackUser user=data.get(position);
        MyBlackViewHolder holder=null;
        if(convertView==null){
            convertView=mInflater.inflate(R.layout.my_black_list_item_view,null);
            holder=new MyBlackViewHolder(convertView);
            convertView.setTag(holder);
        }
        holder=(MyBlackViewHolder)convertView.getTag();
        holder.setUid(user.getUid());
        holder.setPosition(position);
        holder.headView.setImageURI(Uri.parse(user.getAvatar()));
        holder.nickView.setText(user.getNickname());
        String sex=user.getSex();
        if("1".equals(sex)){
            holder.sexView.setImageResource(R.mipmap.user_sex_icon_male);
        }else{
            holder.sexView.setImageResource(R.mipmap.user_sex_icon_female);
        }
        if(!"".equals(user.getLvl())){
            //holder.lv.setVisibility(View.VISIBLE);
            //holder.lv.setImageURI(Uri.parse("asset:///lvIcons/" + user.getLvl() + ".png"));
        }else{
            //holder.lv.setVisibility(View.INVISIBLE);
        }
        holder.setIntroViewText(user.getIntro());
        if(data.size()>0){//最后一条不显示分割线
            if(position==data.size()-1){
                if(holder.divider.getVisibility()==View.VISIBLE){
                    holder.divider.setVisibility(View.INVISIBLE);
                }
            }else{
                if(holder.divider.getVisibility()!=View.VISIBLE){
                    holder.divider.setVisibility(View.VISIBLE);
                }
            }
        }
        return convertView;
    }
}
